package com.github.xiaolyuh.configcenter;


import com.github.xiaolyuh.constant.CacheConstant;

import java.util.Arrays;
import java.util.List;


/**
 * 配置中心
 *
 * @author xuwanglong
 */
public class ConfigCenter {

    public static Boolean allowRedisCache() {
        return Boolean.TRUE;
    }

    public static Boolean allowLocalCache() {
        /*String key = CacheConstant.COUPON_LOCAL_CACHE_ALLOW;
        return PropertiesUtils.getBoolean(key, Boolean.FALSE);*/
        return true;
    }

    public static Integer getLocalCacheExpireTime() {
        /*String key = CacheConstant.COUPON_LOCAL_CACHE_EXPIRE;
        return PropertiesUtils.getInteger(key, CacheConstant.LOCAL_CACHE_DEFAULT_TIMEOUT);*/
        return CacheConstant.LOCAL_CACHE_DEFAULT_TIMEOUT;
    }

    public static Integer getLocalCacheSizeForNormal() {
        // 默认缓存50000张普通券
        /*String key = CacheConstant.COUPON_LOCAL_CACHE_NORMAL_COUPON_LENGTH;
        return PropertiesUtils.getInteger(key, 50000);*/
        return 50000;
    }

    public static Integer getLocalCacheSizeForSystem() {
        // 默认缓存5000张系统券
        /*String key = CacheConstant.COUPON_LOCAL_CACHE_SYSTEM_COUPON_LENGTH;
        return PropertiesUtils.getInteger(key, 15000);*/
        return 15000;
    }

    public static Integer getLocalCacheSizeForActivity() {
        /*String key = CacheConstant.COUPON_LOCAL_CACHE_ACTIVITY_LENGTH;
        return PropertiesUtils.getInteger(key, 1000);*/
        return 1000;
    }

    public static Integer getLocalCacheSizeForActivityIndex() {
        /*String key = CacheConstant.COUPON_LOCAL_CACHE_ACTIVITY_INDEX_LENGTH;
        return PropertiesUtils.getInteger(key, 100000);*/
        return 100000;
    }

    public static List<String> getSiteCodes() {
        String key = CacheConstant.PROMOTION_LOCAL_CACHE_SITE_CODES;
        /*String value = PropertiesUtils.getString(key, CacheConstant.DEFAULT_SITE_CODE);*/
        String value = "";
        return Arrays.asList(value.split(CacheConstant.COMMA));
    }

    public static Integer getSoaIpNum(){
        /*return PropertiesUtils.getInteger(PROMOTION_SOA_IP_NUM,3);*/
        return 3;
    }
}
